{include 'admin/layout/header_list'}
<link rel="stylesheet" href="__ADMIN_STATIC__/css/addContent.css?random={extendSetting('random')}">
<link rel="stylesheet" href="__ADMIN_STATIC__/css/content.css?random={extendSetting('random')}">
<div>
    <form class="ajaxForm" method="post">
        <input type="hidden" name="_method" value="put">
        <input type="hidden" name="roleId" value="{if isset($info['id'])}{$info['id']}{/if}">
        <table class="content-info">
            <tr>
                <td>
                    <span><strong>* </strong>版本{if LT_VERSION==$newVersion['version']}还原{else}更新{/if}</span>
                </td>
                <td>
                    <input class="long" type="text" value="{LT_VERSION} -> {$newVersion?$newVersion['version']:''}" disabled>
                </td>
            </tr>
            <tr>
                <td>
                    <span><strong>* </strong>更新内容</span>
                </td>
                <td>
                    <span > <a href="{$newVersion?$newVersion['contentUrl']:''}" target="_blank">{$newVersion?$newVersion['title']:''}</a></span>
                </td>
            </tr>
            <tr>
                <td>
                    <span><strong>* </strong>只看需要备份</span>
                </td>
                <td>
                    <span ><input  type="checkbox" onclick="onHideIsChange1()" checked ></span>
                </td>
            </tr>
        </table>
        <table class="content-info">
            <tr>
<!--                <th><input id="selectAll" type="checkbox"></th>-->
                <th>文件名</th>
                <th>文件路径</th>
                <th>是否需备份</th>
            </tr>

            {if $md5List}
            {foreach $md5List $key $val}
            <tr class="tr" >
                <td>{$val['file']}</td>
                <td>{$val['path']}</td>
                <td class="isChange{$val['isChange']?'1':'0'}">{$val['isChange']?"被覆盖请备份":"无需备份"}</td>
            </tr>
            {/foreach}
            {/if}
        </table>

    </form>
    <div class="ltcms-button">
        <button  class="submit" onclick="systemUpdate()" >
            确认更新
        </button>
        <button  class="submit" onclick="systemUpdateBackup()" >
            一键备份
        </button>
        <button class="cancel">取消并返回</button>
    </div>
</div>



<script src="__ADMIN_STATIC__/js/addContent.js?random={extendSetting('random')}"></script>
<script src="__ADMIN_STATIC__/js/list.js?random={extendSetting('random')}"></script>
<script >
    function onHideIsChange1() {
        $(".isChange0").parent().toggle() //把没被修改的隐藏了
    }
    onHideIsChange1()
    /*
     系统更新
     */
    function systemUpdate(obj) {
        let msgIndex = layer.msg('正在更新', {
            icon: 16,
            shade: 0.05,
            time:60000
        });
        let id={$newVersion?$newVersion['id']:''}
        //这个注释不能删除,否则报错
        $.post("{LTCMS_ROUTE_PREFIX}/systemUpdate/updateNewVersion",{id:id}, function(json){   // 从服务端异步获取json并执行函数
            layer.close(msgIndex)
            if (json.success){
                layer.msg(json.codeMsg, {icon: 1, time: 1000});
                window.top.location.reload();
            }else {
                layer.msg(json.codeMsg, {icon: 2, time: 1000});
            }
        });

    }
    /*
     一键备份已修改
     */
    function systemUpdateBackup(obj) {
        let msgIndex = layer.msg('正在备份', {
            icon: 16,
            shade: 0.05,
            time:60000
        });
        let id={$newVersion?$newVersion['id']:''}
        //这个注释不能删除,否则报错

        $.post("{LTCMS_ROUTE_PREFIX}/systemUpdate/UpdateBackup",{id:id}, function(json){   // 从服务端异步获取json并执行函数
            layer.close(msgIndex)
            if (json.success){
                layer.msg(json.codeMsg, {icon: 1, time: 1000});
            }else {
                layer.msg(json.codeMsg, {icon: 2, time: 1000});
            }
        });

    }
</script>
<style>
    .isChange1{
        color:#ff0000
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }



</style>

{include 'admin/layout/footer'}